package com.bdmc.smokesensor.dao;
 
import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.bdmc.smokesensor.entity.Sys_Department;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
 
public interface Sys_DepartmentJPA extends JpaRepository<Sys_Department,Integer>,JpaSpecificationExecutor<Sys_Department>,Serializable {
   //public Sys_User findByLoginNameAndPassword(String loginName,String password);
   // public List<Sys_User> findAll(Pageable Pageable);
   @Query(value="select d from Sys_Department d where d.depType=:depType and (d.treeRoot like %:treeRoot% or d.id=:id)")
   public Page<Sys_Department> findByDepTypeAndTreeRootContainingOrId(int depType,String treeRoot,int id,Pageable Pageable);


   public List<Sys_Department> findByDepTypeAndPidNot(int depType ,int pid);

   public List<Sys_Department> findByDepTypeAndPid(int depType ,int pid);

   @Query(value="select new map(d.depName as label,d.id as value) from Sys_Department d where d.depType=:depType and d.treeRoot like %:treeRoot%")
   public List<Map<String,Object>> findByDepTypeAndTreeRootLike(int depType ,String treeRoot);

   

}
